<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
<title>会员中心-{$web_config['web_title']}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="renderer" content="webkit">
<link href="/assets/css/frontend.min.css?v=1.0.1" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
  <script src="/assets/js/html5shiv.js"></script>
  <script src="/assets/js/respond.min.js"></script>
<![endif]-->
        <link href="/assets/css/user.css?v=1.0.1" rel="stylesheet">
		<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    </head>

    <body>
        {include file="header"}
        <main class="content">
            <style>
    .basicinfo {
        margin: 15px 0;
    }

    .basicinfo .row > .col-xs-4 {
        padding-right: 0;
    }

    .basicinfo .row > div {
        margin: 5px 0;
    }
</style>
<div id="content-container" class="container">
    <div class="row">
        {include file="user_left"}
        <div class="col-md-10">
            <div class="panel panel-default ">
                <div class="panel-body">
					<h2 class="page-header">修改密码</h2>
                    <form id="changepwd-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
                        <div class="form-group">
                            <label for="oldpassword" class="control-label col-xs-12 col-sm-2">旧密码:</label>
                            <div class="col-xs-12 col-sm-4">
                                <input type="password" class="form-control" id="oldpassword" name="oldpassword" value="" data-rule="required" placeholder="旧密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="newpassword" class="control-label col-xs-12 col-sm-2">新密码:</label>
                            <div class="col-xs-12 col-sm-4">
                                <input type="password" class="form-control" id="newpassword" name="newpassword" value="" data-rule="required" placeholder="新密码" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="renewpassword" class="control-label col-xs-12 col-sm-2">确认新密码:</label>
                            <div class="col-xs-12 col-sm-4">
                                <input type="password" class="form-control" id="renewpassword" name="renewpassword" value="" data-rule="required" placeholder="确认新密码" />
                            </div>
                        </div>

                        <div class="form-group normal-footer">
                            <label class="control-label col-xs-12 col-sm-2"></label>
                            <div class="col-xs-12 col-sm-8">
                                <div type="submit" class="btn btn-success btn-embossed sub">提交</div>
                            </div>
                        </div>
                    </form>
					
                </div>
            </div>
        </div>
    </div>
</div>
        </main>
		{include file="footer_content"}
<script>
$(".sub").click(function(){
	var oldpassword = $("#oldpassword").val();
	var newpassword  = $("#newpassword").val();
	var	renewpassword  = $("#renewpassword").val();
	
		if(oldpassword == ""){
			alert("ERROR：旧密码不能为空！");
			return false
		}
		
		if(newpassword == ""){
			alert("ERROR：新密码不能为空！");
			return false
		}
		
		if(renewpassword == ""){
			alert("ERROR：确认密码不能为空！");
			return false
		}
		
		if(oldpassword == newpassword){
			alert("ERROR：新密码不能和旧密码相同！");
			return false
		}

		if(newpassword != renewpassword){
			alert("ERROR：新密码与确认密码须要相同！");
			return false
		}
	
	
	$.ajax({
		type:"POST",
		url:"{:url('user/changepwd')}",
		dataType:"json",
		data:{
			oldpassword:oldpassword,
			newpassword:newpassword,
		},
		success:function(res){
			if(res.status == "success"){
				//window.location.reload();
				alert(res.data);
			}else{
				alert(res.data);
			}
		},
		error:function(jqXHR){
			console.log("Error: "+jqXHR.status);
		},
	});
	
});
</script>
    </body>
</html>